package 数组与方法的练习;

public class 求偶数的和 {
    public static void main(String[] args) {
        int[] arr = {29, 35, 38, 56, 21};

        int sum = getSum(arr);

        System.out.println("这个数组偶数的和是"+sum);
    }


    public static int getSum(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0) {
                sum +=arr[i];
            }
        }
        return sum;
    }
}
